package com.yzpass.api.user.dto;

import com.yzpass.api.user.entity.User;
import lombok.Getter;
import lombok.Setter;

import java.util.List;
import java.util.UUID;

@Getter
@Setter
public class UserDTO {
    private String userId;

    private String username;


    private String name;


    private String phone;


    private String email;

    private Boolean isSys;

    private List<String> roleIds;

    public static UserDTO fromUser(User user){
        UserDTO dto = new UserDTO();
        dto.setUserId(user.getUserId().toString());
        dto.setUsername(user.getUsername());
        dto.setName(user.getName());
        dto.setPhone(user.getPhone());
        dto.setEmail(user.getEmail());
        dto.setIsSys(user.getIsSys());
        return dto;
    }
    public User toUser(){
        User user = new User();
        user.setUserId(UUID.fromString(this.getUserId()));
        user.setUsername(this.getUsername());
        user.setName(this.getName());
        user.setPhone(this.getPhone());
        user.setEmail(this.getEmail());
        user.setIsSys(this.getIsSys());
        return user;
    }
}
